//
//  PaymentView.m
//  phmall
//
//  Created by admin on 2017/12/14.
//  Copyright © 2017年 admin. All rights reserved.
//

#import "PaymentView.h"

@implementation PaymentView

-(instancetype)init{
    if (self=[super init]) {
        self.backgroundColor=[UIColor whiteColor];
        self.title=[[UILabel alloc]init];
        [self addSubview:self.title];
        self.title.text=@"请输入支付密码";
        self.title.font=[UIFont systemFontOfSize:18];
        
        self.orange=[[UILabel alloc]init];
        [self addSubview:self.orange];
        self.orange.backgroundColor=[UIColor orangeColor];
        
     
        self.text=[[UILabel alloc]init];
        [self addSubview:self.text];
        self.text.text=@"菲信商城";
        self.text.font=[UIFont systemFontOfSize:15];
        
        self.Tline=[[UILabel alloc]init];
        [self addSubview:self.Tline];
        self.Tline.backgroundColor=[UIColor groupTableViewBackgroundColor];
        
    
        self.passWord =[[TPPasswordTextView alloc] init];
        self.passWord.elementCount = 6;
//        self.passWord.center = CGPointMake(center.x, 50);
        [self addSubview:self.passWord];
        __weak typeof(self) weakself = self;
        self.passWord.passwordDidChangeBlock = ^(NSString *password) {
            NSLog(@"%@",password);
            if(password.length == 6){
                [weakself.delegate Passwordill:password];
            }
        };
        

        self.Bline=[[UILabel alloc]init];
        [self addSubview:self.Bline];
        self.Bline.backgroundColor=[UIColor groupTableViewBackgroundColor];
        
        self.price=[[UILabel alloc]init];
        [self addSubview:self.price];
        self.price.text=@"₱8888.80";
        self.price.textColor=[UIColor orangeColor];
        self.price.font=[UIFont systemFontOfSize:24];
        
        self.type=[UIButton buttonWithType:UIButtonTypeCustom];
        [self addSubview:self.type];
        self.type.titleLabel.font=[UIFont systemFontOfSize:13];
        [self.type setTitle:@"零钱支付" forState:UIControlStateNormal];
        [self.type addTarget:self action:@selector(typeAction) forControlEvents:UIControlEventTouchUpOutside];
        [self.type setImage:[UIImage imageNamed:@"零钱"] forState:UIControlStateNormal];
        [self.type setTitleColor:[UIColor colorWithHexString:@"#adadad"] forState:UIControlStateNormal];
        [self.type layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleLeft imageTitleSpace:5];
    }
    return self;
}
-(void)layoutSubviews{
    [super layoutSubviews];
    CGSize superSize = self.frame.size;
    
    if (CGSizeEqualToSize(superSize, CGSizeZero)) {
        return;
    }
    [self.title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.offset(0);
        make.top.offset(0);
        make.height.offset(44);
    }];
    
    [self.orange mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.offset(0);
        make.top.offset(44);
        make.height.offset(1);
    }];
    
    [self.text mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.offset(0);
        make.top.equalTo(self.orange.mas_bottom).offset(15);
    }];
    
    [self.price mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.offset(0);
        make.bottom.equalTo(self.Tline.mas_bottom).offset(-15);
    }];
    
    [self.Tline mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(20);
        make.right.offset(-20);
        make.height.offset(1);
        make.top.equalTo(self.orange).offset(84);
    }];
    
    [self.passWord mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(20);
        make.right.offset(-20);
        make.height.offset(41);
        make.top.equalTo(self.Tline).offset(22);
    }];
    
    [self.Bline mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(20);
        make.right.offset(-20);
        make.height.offset(1);
        make.bottom.offset(-44);
    }];
    
    [self.type mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(20);
        make.height.offset(44);
        make.bottom.offset(0);
    }];
}
-(void)typeAction{
    
}
@end
